﻿//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Text;

//using Microsoft.VisualStudio.TestTools.UnitTesting;

//using Pibby.Core.Opml;

//using Pibby.Core.IntegrationTests.Stubs;

//namespace Pibby.Core.Tests
//{
//    [TestClass]
//    public class OpmlDocumentTests : IntegrationBaseTestFixture
//    {
//        //[TestMethod]
//        //[ExpectedException(typeof(FileNotFoundException))]
//        //public void Import_MissingFile_ThrowsException()
//        //{
//        //    //OpmlDocument opml = OpmlDocument.Load("This file _probably_ does not exist in the filesystem");
//        //}

//        [TestMethod]
//        [ExpectedException(typeof(ArgumentNullException))]
//        public void Import_NullTextReader_ThrowsException()
//        {
//            TextReader tr = null;

//            OpmlDocument opml = OpmlDocument.Load(tr);
//        }

//        [TestMethod]
//        [ExpectedException(typeof(ArgumentNullException))]
//        public void Import_NullXmlDocument_ThrowsException()
//        {
//            System.Xml.XmlDocument xml = null;

//            OpmlDocument rss = OpmlDocument.Load(xml);
//        }

//        [TestMethod]
//        public void Import_NoSubscriptions_LoadsNoOutlines()
//        {
//            OpmlDocumentGenerator generator = new OpmlDocumentGenerator(0);

//            OpmlDocument opml = OpmlDocument.Load(generator.ContentStream);

//            Assert.AreEqual(generator.OpmlVersion, opml.Version, "Version not read correctly");
//            Assert.AreEqual(generator.TitleText, opml.Title, "Title not read correctly");
//            Assert.AreEqual(generator.OwnerName, opml.OwnerName, "Owner name not read correctly");
//            Assert.AreEqual(generator.OwnerId, opml.OwnerId, "Owner id not read correctly");
//            Assert.AreEqual(DateTime.Today, opml.ModifiedDate, "Modified date not read correctly");

//            //Assert.IsEmpty(opml.Outlines, "Outline collection should be empty");
//        }

//        [TestMethod]
//        public void Import_SingleSubscription_LoadsOneOutline()
//        {
//            OpmlDocumentGenerator generator = new OpmlDocumentGenerator(1);

//            OpmlDocument opml = OpmlDocument.Load(generator.ContentStream);

//            //Assert.IsNotEmpty(opml.Outlines, "Outline collection should not be empty");
//            Assert.AreEqual(1, opml.Outlines.Count);

//            Assert.AreEqual(string.Format(generator.OutlineFormatString, 1),
//                            opml.Outlines[0].Title, "Outline details not read correctly");
//        }

//        [TestMethod]
//        public void Import_MultipleSubscriptions_LoadsMultipleOutlines()
//        {
//            const int howMany = 10;
//            OpmlDocumentGenerator generator = new OpmlDocumentGenerator(howMany);

//            OpmlDocument opml = OpmlDocument.Load(generator.ContentStream);

//            //Assert.IsNotEmpty(opml.Outlines, "Outline collection should not be empty");
//            Assert.AreEqual(howMany, opml.Outlines.Count);

//            for (int i = 0; i < howMany; ++i)
//            {
//                Assert.AreEqual(string.Format(generator.OutlineFormatString, i + 1), 
//                                    opml.Outlines[i].Title, "Outline details not read correctly");

//                Assert.AreEqual(string.Format(generator.OutlineFormatString, i + 1),
//                                    opml.Outlines[i].Text);

//                Assert.AreEqual(new Uri (string.Format("http://podcast{0}", i + 1)), opml.Outlines[i].XmlUrl);
//                Assert.AreEqual(new Uri(string.Format("http://podcast{0}/" + generator.OutlineFormatString, i + 1, i + 1)), opml.Outlines[i].HtmlUrl);
//                Assert.AreEqual(OutlineType.Rss, opml.Outlines[i].OutlineType);
//            }
//        }

//        [TestMethod]
//        public void Export_ImportingExportedDocument_MatchesOriginal()
//        {
//            const int howMany = 10;
//            OpmlDocumentGenerator generator = new OpmlDocumentGenerator(howMany);

//            OpmlDocument imported = OpmlDocument.Load(generator.ContentStream);

//            //Assert.IsNotEmpty(imported.Outlines, "Outline collection should not be empty");
//            Assert.AreEqual(howMany, imported.Outlines.Count);

//            OpmlDocument exported = new OpmlDocument();

//            foreach (Outline outline in imported.Outlines)
//            {
//                exported.Outlines.Add(outline);
//            }

//            using (TextReader importReader = new StringReader (exported.ToString ()))
//            {
//                OpmlDocument importedAgain = OpmlDocument.Load (importReader);

//                Assert.AreEqual(imported.Outlines.Count, importedAgain.Outlines.Count);
//            }
//        }

//        [TestMethod]
//        public void File_LoadSave_ExtensionsAreCorrect()
//        {
//            Assert.IsTrue(OpmlDocument.FileExtension.Contains ("opml"));
//            Assert.IsTrue(OpmlDocument.FileFilter.Contains("*.opml"));
//            Assert.IsTrue(OpmlDocument.FileFilter.Contains ("*.xml"));
//        }
//    }
//}
